//
//  ViewController.m
//  UI29-TableVIew(TranistionAnimation)
//
//  Created by 韩旭 on 16/8/23.
//  Copyright © 2016年 HX_. All rights reserved.
//

#import "ViewController.h"
#import "DetailViewController.h"
#import "PushAnimation.h"
#import "Hx_TableViewCustom.h"
#import "PopAnimation.h"

@interface ViewController ()<UITableViewDataSource, UITableViewDelegate, UINavigationControllerDelegate>
@property (nonatomic, strong) NSString *string;
@property (nonatomic, strong) UITableView *tableView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatTableView];
    self.navigationController.delegate = self;
}
- (void)creatTableView {
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kWidth, kHeight) style:0];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
    [_tableView registerNib:[UINib nibWithNibName:@"Hx_TableViewCustom" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"reuse"];
}
- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC {
    if (operation == UINavigationControllerOperationPush) {
        PushAnimation *push = [[PushAnimation alloc] init];
        return push;
    } else if (operation == UINavigationControllerOperationPop) {
        
        PopAnimation *pop = [[PopAnimation alloc] init];
        return pop;
    } else {
    }
    return nil;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 20;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     self.customCell = [_tableView dequeueReusableCellWithIdentifier:@"reuse"];
    _customCell.backgroundColor = COLORAUTO;
    _customCell.ImageForm.image = [UIImage imageNamed:@"6d5a141f37765211d6c3713e58207c52.jpg"];
    return _customCell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    DetailViewController *detail = [[DetailViewController alloc] init];
    detail.stirng = @"6d5a141f37765211d6c3713e58207c52.jpg";
    Hx_TableViewCustom *cell = [tableView cellForRowAtIndexPath:indexPath];
    self.newRect = [cell convertRect:self.customCell.ImageForm.frame toView:self.view];
    [self.navigationController pushViewController:detail animated:YES];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 200;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
